package com.naiterui.ehp.bp.utils.lang;

import cn.hutool.extra.pinyin.PinyinUtil;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class FirstLetterUtil {

    /**
     * 获取字符串的首字母的大写
     */
    public static String getNameFristChar(String name) {
        String pyStr = PinyinUtil.getPinyin(name).toUpperCase();
        log.info("获取拼音 :{}", pyStr);
        if (!"".equals(pyStr)) {
            char letter = pyStr.charAt(0);
            if (letter >= 'A' && letter <= 'Z') {
                return String.valueOf(letter);
            }
        }
        return "#";
    }

}
